package com.example.attempt.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
public class Post {
    @TableId(value = "pid",type = IdType.AUTO)
    private int pid;
    private String ptitle;
    private String pcontent;
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")      // 表示接收时间类型
    private LocalDateTime ptime;
    private String sid;
    private String tid;
    private String aid;
    private String cid;

    public void setPtime(){
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String time = LocalDateTime.now().format(df);
        this.ptime = LocalDateTime.parse(time, df);
    }

}
